package org.six11.ss.client;

import org.six11.ss.shared.Message;
import org.six11.util.adt.MultiState;

/**
 * 
 * 
 * @author Gabe Johnson <johnsogg@cmu.edu>
 */
public class SketchDoneMessageHandler extends AWTMessageHandler {

  /**
   * @param state
   */
  public SketchDoneMessageHandler(MultiState state) {
    super(state);
  }

  /**
   * 
   */
  @Override
  public void handleAWT(Message msg) {
    long whenElapsed = (Long) state.getValue(ClientStateNames.K_ROUND_ELAPSED);
    long maybeNewElapse = System.currentTimeMillis() + Long.parseLong(msg.getParam("when"));
    if (maybeNewElapse < whenElapsed) {
      // move schedule up!
      state.setValue(ClientStateNames.K_ROUND_ELAPSED, maybeNewElapse);
      state.whackValue(ClientStateNames.K_SKETCH_DONE);
      state.setValue(ClientStateNames.K_GLASS_MESSAGE, "Sketching done! Hurry!");
    } 
  }

}
